package com.lovo.shirodemo.controller;


import com.lovo.shirodemo.model.dto.UserInfoDTO;
import com.lovo.shirodemo.result.ResponseResult;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bdk
 * @since 2020-11-26
 */
@RestController
@RequestMapping("/users")
public class UserInfoController {
    @PostMapping("/login")
    @ResponseResult
    public Object login(@RequestBody UserInfoDTO userInfoDTO){
        UsernamePasswordToken token = new UsernamePasswordToken(userInfoDTO.getPhone(),userInfoDTO.getPwd());
        Subject currentUser = SecurityUtils.getSubject();
        currentUser.login(token);
        return null;
    }
}

